﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using System.Data;
using BangleCMS.DBUtility;

namespace BangleCMS.DAL
{
	/// <summary>
	/// 数据访问类:web_configDAL
	/// </summary>
	public partial class web_configDAL
	{
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BangleCMS.Model.web_config GetModel(string ConfigKey)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ConfigId,ConfigKey,ConfigValue,Remark from web_config ");
            strSql.Append(" where ConfigKey=@ConfigKey LIMIT 1");
            MySqlParameter[] parameters = {
					new MySqlParameter("@ConfigKey", MySqlDbType.String)
			};
            parameters[0].Value = ConfigKey;

            BangleCMS.Model.web_config model = new BangleCMS.Model.web_config();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ConfigId"] != null && ds.Tables[0].Rows[0]["ConfigId"].ToString() != "")
                {
                    model.ConfigId = int.Parse(ds.Tables[0].Rows[0]["ConfigId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ConfigKey"] != null && ds.Tables[0].Rows[0]["ConfigKey"].ToString() != "")
                {
                    model.ConfigKey = ds.Tables[0].Rows[0]["ConfigKey"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ConfigValue"] != null && ds.Tables[0].Rows[0]["ConfigValue"].ToString() != "")
                {
                    model.ConfigValue = ds.Tables[0].Rows[0]["ConfigValue"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Remark"] != null && ds.Tables[0].Rows[0]["Remark"].ToString() != "")
                {
                    model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }
    }
}
